package what.basic.basiccomponent;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Jdialog extends JPanel{
	Jdialog(){
		JFrame f=new JFrame("dialog window test");
		Toolkit kit=Toolkit.getDefaultToolkit();
		Dimension sz=kit.getScreenSize();
		f.setSize(300,200);
		int width=sz.width;
		int height=sz.height;
		int x=(width-f.WIDTH)/2;
		int y=(height-f.HEIGHT)/2;
		f.setLocation(x, y);
		f.setContentPane(this);
		f.setVisible(true);
		
		setLayout(new FlowLayout());
		JButton b1=new JButton("showMessageDialog");
		JButton b2=new JButton("showConfirmDialog");
		JButton b3=new JButton("showOptionDialog");
		JButton b4=new JButton("shwoInputDialog");
		add(b1);
		add(b2);
		add(b3);
		add(b4);
		b1.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				String message="this is a message dialog window";
				JOptionPane.showMessageDialog(null, message);
			}
		});
		b2.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
			String message="this is a confirm dialog window";
			JOptionPane.showConfirmDialog(null, message,message,JOptionPane.YES_NO_CANCEL_OPTION);
			}
			});
		b3.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				Object[] options={"OK","CANCEL"};
			String message="click OK continue";
			JOptionPane.showOptionDialog(null, message,"alert",JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE,null,options,options[0]);
			}
			});
		b4.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				Object[] options={"first","second","third"};
			String message="this is a input dialog window";
			JOptionPane.showInputDialog(null, message,"input",JOptionPane.INFORMATION_MESSAGE,new ImageIcon("blue.gif"),options,options[0]);
			}
			});
	}
	public static void main(String[] args) {
		new Jdialog();

	}

}
